home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************
- ** ScanToConfig **
- ** **
- ** Builds the MMU-Configuration file automatically **
- ** from the MuScan output, including kludges for **
- ** bad or mis-designed hardware **
- ** Version 1.01 © 1999 THOR-Software, Thomas Richter **
- ** 11.01.2000 **
- *********************************************************/
-
- PARSE ARG destination .
-
- if (destination = '') then
- destination = '*'
-
-
- rec = 25;
-
- if (OPEN(.out,destination,'W')) THEN; DO
- rv=WRITELN(.out,";*************************************************************************");
- rv=WRITELN(.out,";** MMU Configuration file **");
- rv=WRITELN(.out,";** **");
- rv=WRITELN(.out,";** this file is read on startup by the mmu.library and used to modify **");
- rv=WRITELN(.out,";** the pre-calculated or scanned MMU table **");
- rv=WRITELN(.out,";** **");
- rv=WRITELN(.out,";** © 1999 THOR Software, Thomas Richter **");
- rv=WRITELN(.out,";*************************************************************************");
- rv=WRITELN(.out,"");
- rv=WRITELN(.out,"");
- rv=WRITELN(.out,"");
- rv=WRITELN(.out,"; the current version of the MMU library knows four commands that can");
- rv=WRITELN(.out,"; be used in this file:");
- rv=WRITELN(.out,"; CLEARTTX clears all or parts of the transparent translation registers");
- rv=WRITELN(.out,"; ADDMEM adds memory to the exec free list pool. BE WARNED, this command");
- rv=WRITELN(.out,"; does NOT modify the MMU tables, this must be done manually with");
- rv=WRITELN(.out,"; SETCACHEMODE");
- rv=WRITELN(.out,"; SETCACHEMODE defines the MMU tables.");
- rv=WRITELN(.out,"; DESCRIPTORCACHEINHIBIT defines whether the data cache should be disabled");
- rv=WRITELN(.out,"; for the MMU descriptors. It's usually OFF meaning the cache will remain");
- rv=WRITELN(.out,"; enabled. This is fine for the mmu.library, but certain hacks might require");
- rv=WRITELN(.out,"; an ON argument here. Note that this means more work for the library.");
- rv=WRITELN(.out,"");
- rv=WRITELN(.out,"");
- rv=WRITELN(.out,"ClearTTx ;ignore all TTX registers if any. We don't need them");
- rv=WRITELN(.out,"");
- rv=WRITELN(.out,";DescriptorCacheInhibit ON ;make access to MMU descriptors cache inhibited");
- rv=WRITELN(.out,"");
- rv=WRITELN(.out,"");
- rv=WRITELN(.out,";Board specific setup follows here,");
- rv=WRITELN(.out,";generated by ScanToConfig 1.00 © 1999 THOR-Software");
- rv=WRITELN(.out,"");
-
- rv=WRITELN(.out,";General memory setup follows.");
- rv=WRITELN(.out,";The following lines are a compatibility cludge for some P5 boards");
- rv=WRITELN(.out,";which enable the MMU prior to the 68040/68060 library and leave");
- rv=WRITELN(.out,";the memory in CACHEINHIBIT state. You may remove the following");
- rv=WRITELN(.out,";lines on all other machines most likely.");
- rv=WRITELN(.out,"");
-
- ADDRESS COMMAND "MemModes >T:MemInfo";
- IF (OPEN(.meminfo,"T:MemInfo",'R')) THEN; DO
- DO UNTIL EOF(.meminfo)
- line = READLN(.meminfo);
- WRITELN(.out,line);
- END;
- rv=CLOSE(.meminfo);
- END;
-
- rv=WRITELN(.out,";Memory setup end.");
- rv=WRITELN(.out,"");
- rv=WRITELN(.out,"");
-
- ADDRESS COMMAND 'FindPort "BOOT-MMU-Port"'
- portmode = RC;
-
- ADDRESS COMMAND "ShowBoards to T:BoardInfo";
- boards = 0;
- if (OPEN(.boardinfo,"T:BoardInfo",'R')) then; do
- DO UNTIL EOF(.boardinfo)
- line = READLN(.boardinfo)
- IF line ~= '' THEN; DO
- PARSE VAR line 'Type:' type 'Product:' product 'Manufacturer:' mf 'Serial#:' id 'BoardAddr:' from 'BoardSize:' size;
- boards = boards + 1;
- type.boards=X2D(type);
- product.boards=X2D(product);
- mf.boards=X2D(mf);
- id.boards=X2D(id);
- base.boards=X2D(SUBSTR(from,2,6));
- end.boards=X2D(SUBSTR(size,2,6))+base.boards;
- END
- END
- rv=CLOSE(.boardinfo);
- END
- ADDRESS COMMAND "MuScan to T:BoardInfo";
- if (OPEN(.boardinfo,"T:BoardInfo",'R')) then; do
- rec = 0;
- scan = 0;
- portwarn = 0;
- ppcwarn = 0;
- DO UNTIL EOF(.boardinfo)
- line = READLN(.boardinfo)
- IF scan = 0 THEN; DO
- IF line = 'Memory map:' THEN; DO
- scan = 1;
- END;
- END; ELSE; DO
- IF line ~= '' THEN; DO
- base = SUBWORD(line,1,1);
- end = SUBWORD(line,3,1);
- mode = SUBWORD(line,4);
- rv = ScanEntry(base,end,mode);
- END;
- END
- END
- rv=CLOSE(.boardinfo);
- END
-
- IF portmode = 0 THEN;DO
- rv=WRITELN(.out,"");
- rv=WRITELN(.out,";Several P5 boards build a private MMU setup on boot");
- rv=WRITELN(.out,";using a kludge called the BOOT-MMU-Port. To run this");
- rv=WRITELN(.out,";kludge, the following external command is run from");
- rv=WRITELN(.out,";LIBS:mmu/ as all other external commands");
- rv=WRITELN(.out,"ScanMMUPort");
- IF ~EXISTS("LIBS:mmu") THEN; DO
- OPTIONS FAILAT 15
- ADDRESS COMMAND 'MakeDir >NIL: LIBS:MMU/'
- OPTIONS FAILAT 10
- END;
- IF ~EXISTS("LIBS:mmu/ScanMMUPort") THEN; DO
- ADDRESS COMMAND 'Copy >NIL: ScanMMUPort to LIBS:MMU/ScanMMUPort'
- END;
- rv=WRITELN(.out,";SetCacheMode FROM 0xFFFF8000 SIZE 0x00008000 VALID CACHEINHIBIT");
- rv=WRITELN(.out,"");
- END;
-
- END
-
- RETURN 0
-
-
- ScanEntry:
- PARSE ARG base,end,mode
-
- base = X2D(SUBSTR(base,3,6))
- end = X2D(SUBSTR(end,3,6))+1
-
- copyback = INDEX(mode,'CopyBack')>0;
- cacheinhibit = INDEX(mode,'CacheInhibit')>0;
- invalid = INDEX(mode,'Blank')>0 | INDEX(mode,'Invalid')>0;
- remapped = INDEX(mode,'Remapped')>0;
- speedup = INDEX(mode,'NonSerial')>0 | INDEX(mode,'Imprecise')>0;
- iomark = 0;
- board = 0;
-
- DO i=1 TO boards
- IF base<end.i & end>base.i THEN; DO
- iomark = 1;
- END;
- END;
-
- cachemodes = "WriteThrough";
- iomodes = "";
- IF copyback THEN cachemodes="CopyBack";
- IF cacheinhibit THEN cachemodes="CacheInhibit";
- IF speedup THEN cachemodes="CacheInhibit Imprecise NonSerial";
- IF iomark THEN iomodes="IOSpace";
-
- memrange = "SetCacheMode 0x"D2X(base)"00 Size 0x"D2X(end-base)"00";
-
- zeropage = 0;
- chipmem = 0;
- zorro2 = 0;
- iospace = 0;
- mother = 0;
- rangermem = 0;
- p5space = 0;
- ppcspace = 0;
- mem = 0;
- rom = 0;
-
- IF end<=X2D('80') THEN zeropage = 1;
- IF end<=X2D('2000') THEN chipmem = 1;
- IF base>=X2D('2000') & end<=X2D('A000') THEN zorro2 = 1;
- IF base>=X2D('A000') & end<=X2D('B800') THEN iospace = 1;
- IF base>=X2D('B800') & end<=X2D('C000') THEN mother = 1;
- IF base>=X2D('C000') & end<=X2D('D800') THEN rangermem = 1;
- IF base>=X2D('DA00') & end<=X2D('E000') THEN mother = 1;
- IF base>=X2D('E800') & end<=X2D('F000') THEN iospace = 1;
- IF base>=X2D('F000') & end<=X2D('F800') THEN p5space = 1;
- IF base>=X2D('F800') & end<=X2D('10000') THEN rom = 1;
- IF base>=X2D('10000') & end<=X2D('100000') THEN mem = 1;
- IF base>=X2D('80000') & end<=X2D('100000') THEN ppcspace = 1;
- IF base>=X2D('100000') & end<=X2D('800000') THEN iospace = 1;
- IF base>=X2D('400000') & end<=X2D('C00000') THEN ppcspace = 1;
- IF base>=X2D('E00000') & end<=X2D('1000000') THEN p5space = 1;
- IF base>=X2D('FF0000') & end<=X2D('FF1000') THEN iospace = 1;
- IF iomark THEN iospace = 1;
-
- /* found remapped chip memory */
- IF zeropage & remapped THEN; DO
- SAY 'Found a remapped ZeroPage, it might be a good idea to run MuFastZero.';
- SAY 'If MuFastZero fails with "Zero page already remapped", please add the';
- SAY 'FORCENATIVE command line option.';
- END;
-
- /* found fast chip. This can be turned on in either case */
- IF chipmem & (~remapped) & (~invalid) THEN; DO
- rv=WRITELN(.out,";In case you don't run the V40 68040 resp. 68060.library");
- rv=WRITELN(.out,";the following line will speed up the chip memory. It is");
- rv=WRITELN(.out,";not required otherwise.");
- rv=WRITELN(.out,memrange "CacheInhibit Imprecise NonSerial");
- rv=WRITELN(.out,"");
- END;
-
- /* found slow zorro II or gfx mem? */
- IF zorro2 & (~copyback) & (~invalid) & (~iomark) THEN; DO
- rv=WRITELN(.out,";Found slow Zorro-II memory. Keeping the caches disabled.");
- rv=WRITELN(.out,memrange "CacheInhibit Imprecise NonSerial Valid");
- rv=WRITELN(.out,"");
- END;
-
- /* copy attributes for the IO space */
- IF iospace & (~invalid) & (~remapped) THEN; DO
- rv=WRITELN(.out,memrange cachemodes "Valid IOSpace");
- rv=WRITELN(.out,"");
- END;
-
- /* setup ranger memory */
- IF rangermem & (~invalid) & (~remapped) THEN; DO
- rv=WRITELN(.out,memrange "CacheInhibit Imprecise NonSerial Valid");
- rv=WRITELN(.out,"");
- END;
-
- /* setup P5 uglyness */
- IF p5space & (~invalid) & (~remapped) & (~iospace) THEN; DO
- rv=WRITELN(.out,";The following memory region should be left blank");
- rv=WRITELN(.out,";according to the CBM design rules. It isn't...");
- rv=WRITELN(.out,memrange cachemodes "Valid IOSpace");
- rv=WRITELN(.out,"");
- END;
-
- /* found remapped ROM? */
- IF rom & remapped THEN; DO
- SAY 'Found a remapped ROM, running MuFastRom might be a good idea,';
- SAY 'but make sure you disable other ROM remappers before trying';
- SAY 'to use the MMU.library setup.';
- END;
-
- /* strange caching modes in RAM? */
- IF mem THEN; DO
- IF ~copyback THEN; DO
- IF ~portwarn THEN; DO
- SAY 'WARNING! Found non-copyback memory regions.';
- SAY 'This could mean that either the ppc.library is running';
- SAY 'or P5 I/O hardware is active.';
- SAY 'For the time being, I do nothing about it, but you should';
- SAY 'check the MMU-Configuration file manually and follow the';
- SAY 'notes in this file for further testing.';
- rv=WRITELN(.out,"WARNING! Found non-copyback memory regions.");
- rv=WRITELN(.out,"This could mean that either the ppc.library is running");
- rv=WRITELN(.out,"or P5 I/O hardware is active.");
- rv=WRITELN(.out,"For the time being, I do nothing about it, but you could");
- rv=WRITELN(.out,"try to remove the semi-colon for the following lines:");
- portwarn = 1;
- END;
- rv=WRITELN(.out,";"memrange cachemodes "Valid");
- END;
- END;
-
- /* PPC memory area marked as valid? */
- IF ppcspace & (~invalid) & (~remapped) THEN; DO
- IF ~ppcwarn THEN; DO
- SAY 'WARNING! Found possible PPC memory regions.';
- SAY 'DO NOT RUN THE ppc.library or you get problems.';
- ppcwarn = 1;
- END;
- rv=WRITELN(.out,";If you don't own a PPC, you may remove the next line:");
- rv=WRITELN(.out,memrange cachemodes iomodes "Valid");
- rv=WRITELN(.out,"");
- END;
-
-
- RETURN 0
-